home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / Xmfbpmax / sys / tty.h < prev   
Encoding:
C/C++ Source or Header  |  1990-04-24  |  9.6 KB  |  279 lines

  1.  
  2. /*
  3.  *    @(#)tty.h    4.1.1.9     (ULTRIX)        11/9/88
  4.  */
  5.  
  6. /*
  7.  * tty.h
  8.  */
  9.  
  10.  
  11. /************************************************************************
  12.  *                                    *
  13.  *            Copyright (c) 1983-1988 by            *
  14.  *        Digital Equipment Corporation, Maynard, MA        *
  15.  *            All rights reserved.                *
  16.  *                                    *
  17.  *   This software is furnished under a license and may be used and    *
  18.  *   copied  only  in accordance with the terms of such license and    *
  19.  *   with the  inclusion  of  the  above  copyright  notice.   This    *
  20.  *   software  or  any  other copies thereof may not be provided or    *
  21.  *   otherwise made available to any other person.  No title to and    *
  22.  *   ownership of the software is hereby transferred.            *
  23.  *                                    *
  24.  *   This software is  derived  from  software  received  from  the    *
  25.  *   University    of   California,   Berkeley,   and   from   Bell    *
  26.  *   Laboratories.  Use, duplication, or disclosure is  subject  to    *
  27.  *   restrictions  under  license  agreements  with  University  of    *
  28.  *   California and with AT&T.                        *
  29.  *                                    *
  30.  *   The information in this software is subject to change  without    *
  31.  *   notice  and should not be construed as a commitment by Digital    *
  32.  *   Equipment Corporation.                        *
  33.  *                                    *
  34.  *   Digital assumes no responsibility for the use  or  reliability    *
  35.  *   of its software on equipment which is not supplied by Digital.    *
  36.  *                                    *
  37.  ************************************************************************/
  38.  
  39. /*************************************************************************
  40.  *            Modification History
  41.  *
  42.  *        April 4, 1985  -- Larry Cohen
  43.  *    001    add TS_CLOSING state to signify that tty line is closing
  44.  *        down and should not be opened until closed completely.
  45.  *        Primarily to ensure DTR is kept down "long enough"
  46.  *
  47.  *        April 13, 1985 -- Larry Cohen
  48.  *    002     add TS_INUSE to sigify that tty line is "in use" by
  49.  *        another process.  Advisory in nature.  Always cleared
  50.  *        when the process that set this flag exits or closes
  51.  *        the file descriptor associated with the line.
  52.  *
  53.  *        10/1/85 -- Larry Cohen
  54.  *    003    add t_winsiz to tty structure.
  55.  *    
  56.  *        1/22/85 -- Larry Cohen
  57.  *        DEC standard 52 support.  MODEM definitions.
  58.  *
  59.  *        03/06/86 -- Miriam Amos
  60.  *        Add t_iflag, t_oflag, t_cflag, and t_lflag for
  61.  *        termio interface.
  62.  *
  63.  *        06/17/86 -- Tim Burke
  64.  *         Added two state definitions (TS_LRTO, TS_LTACT) which are used
  65.  *        in termio min/time interaction to specify that a timeout is in
  66.  *            progress and that the min/time has been examined.
  67.  *
  68.  *        08/14/86 -- Tim Burke
  69.  *        Added one #define for VAXstar SLU driver dec standard 52.
  70.  *
  71.  *        08/26/86 -- Tim Burke
  72.  *        Changed name of #define added on 8/14/86.
  73.  *
  74.  *        05/25/87 -- Tim Burke
  75.  *        Added termio to list of include files
  76.  *
  77.  *        07/28/87 -- Tim Burke
  78.  *        Add some defines from Andy Gadsby which are used for 8-bit
  79.  *        processing in the terminal driver.
  80.  *
  81.  *        12/01/87 -- Tim Burke
  82.  *        Modified tty structure to allow terminal attributes to be
  83.  *        stored in the POSIX termios data structure instead of t_flags,
  84.  *        tchars, and ltchars.
  85.  *        Defined 1 new terminal state.
  86.  *        TS_ISUSP    - input is suspended.
  87.  *
  88.  *        12/12/87 -- Tim Burke
  89.  *        Added t_language field to provide a hook for local language
  90.  *        extensions such as Japanese tty.  The intent is that each
  91.  *        language will add their own local language structure to a union
  92.  *        of languages.  For example it may look like:
  93.  *
  94.  *            union local_ext {
  95.  *                struct jtty jtp;    -- Japanese --
  96.  *                struct gtty gtp;    -- German --
  97.  *                struct ftty ftp;    -- French --
  98.  *            };
  99.  *
  100.  *        03/10/88 -- Tim Burke
  101.  *        Added a new state TS_OABORT.  This state indicates that output
  102.  *        has been suspended after seeing a stop character.  This state
  103.  *        will notify the start routine that it only has to continue.
  104.  */
  105. #ifdef KERNEL
  106. #include "../h/ttychars.h"
  107. #include "../h/ttydev.h"
  108. #include "../h/termios.h"
  109. #else
  110. #include <sys/ttychars.h>
  111. #include <sys/ttydev.h>
  112. #include <sys/termios.h>
  113. #endif
  114. #ifndef _TTY_
  115. #define _TTY_
  116. #endif _TTY_
  117.  
  118. /*
  119.  * A clist structure is the head of a linked list queue
  120.  * of characters.  The characters are stored in blocks
  121.  * containing a link and CBSIZE (param.h) characters. 
  122.  * The routines in tty_subr.c manipulate these structures.
  123.  */
  124. struct clist {
  125.     int    c_cc;        /* character count */
  126.     char    *c_cf;        /* pointer to first char */
  127.     char    *c_cl;        /* pointer to last char */
  128. };
  129.  
  130. /*
  131.  * Per-tty structure.
  132.  *
  133.  * Should be split in two, into device and tty drivers.
  134.  * Glue could be masks of what to echo and circular buffer
  135.  * (low, high, timeout).
  136.  */
  137. struct tty {
  138.     union {
  139.         struct {
  140.             struct    clist T_rawq;
  141.             struct    clist T_canq;
  142.         } t_t;
  143.         struct {
  144.             struct    buf *T_bufp;
  145.             char    *T_cp;
  146.             int    T_inbuf;
  147.             int    T_rec;
  148.         } t_n;
  149.     } t_nu;
  150.     struct {
  151.         struct    buf *H_bufp;    /* used in tty_bk, tty_hc, tty_tb */
  152.         char    *H_in;
  153.         char    *H_out;
  154.         char     *H_base;
  155.         char    *H_top;
  156.         int    H_inbuf;
  157.         int    H_read_cnt;
  158.         } t_h;
  159.     struct    clist t_outq;        /* device */
  160.     int    (*t_oproc)();        /* device */
  161.     struct    proc *t_rsel;        /* tty */
  162.     struct    proc *t_wsel;
  163.     caddr_t    T_LINEP;        /* used only in tty_tb.c */
  164.     caddr_t    t_addr;            /* ??? */
  165.     dev_t    t_dev;            /* device */
  166.     unsigned int    t_flags;        /* some of both */
  167.     unsigned short    t_iflag;    /* termio input modes */
  168.     unsigned short    t_iflag_ext;    /* POSIX extensions to iflag */
  169.     unsigned short    t_oflag;    /* termio output modes */
  170.     unsigned short    t_oflag_ext;    /* POSIX extensions to oflag */
  171.     unsigned short    t_cflag;    /* termio control modes */
  172.     unsigned short    t_cflag_ext;    /* POSIX extensions to cflag */
  173.     unsigned short    t_lflag;    /* termio line discipline modes */
  174.     unsigned short    t_lflag_ext;    /* POSIX extensions to lflag */
  175.     unsigned char    t_cc[NCCS];    /* termio control chars */
  176.     unsigned int    t_state;    /* some of both */
  177.     short    t_pgrp;            /* controling process number */
  178.     char    t_delct;        /* tty */
  179.     char    t_line;            /* line discipline */
  180.     char    t_col;            /* tty */
  181.     char    t_rocount, t_rocol;    /* tty */
  182.     struct    winsize t_winsize;    /* window size */
  183.     union    local_ext *t_language;    /* For local language extensions */
  184. };
  185.  
  186.  
  187. #define    t_rawq    t_nu.t_t.T_rawq        /* raw characters or partial line */
  188. #define    t_canq    t_nu.t_t.T_canq        /* raw characters or partial line */
  189.  
  190. #define    t_bufp    t_nu.t_n.T_bufp        /* buffer allocated to protocol */
  191. #define    t_cp    t_nu.t_n.T_cp        /* pointer into the ripped off buffer */
  192. #define    t_inbuf    t_nu.t_n.T_inbuf    /* number chars in the buffer */
  193. #define    t_rec    t_nu.t_n.T_rec        /* have a complete record */
  194. #define    h_bufp    t_h.H_bufp        /* buffer allocated to protocol */
  195. #define    h_in    t_h.H_in        /* next input position in buffer */
  196. #define    h_out    t_h.H_out        /* next output position in buffer */
  197. #define    h_base    t_h.H_base        /* pointer to base of buffer */
  198. #define    h_top    t_h.H_top        /* pointer to top of buffer */
  199. #define    h_inbuf    t_h.H_inbuf    /* number chars in the buffer */
  200. #define    h_read    t_h.H_read_cnt    /* number chars to read in */
  201.  
  202. #define MODEM_CD   0x01
  203. #define MODEM_DSR  0x02
  204. #define MODEM_CTS  0x04
  205. #define MODEM_DSR_START  0x08
  206. #define MODEM_BADCALL 0x10
  207.  
  208. #define    TTIPRI    28
  209. #define    TTOPRI    29
  210.  
  211. /* limits */
  212. #define    NSPEEDS    16
  213. #define    TTMASK    15
  214. #define    OBUFSIZ    100
  215. #define    TTYHOG    255
  216. #ifdef KERNEL
  217. short    tthiwat[NSPEEDS], ttlowat[NSPEEDS];
  218. #define    TTHIWAT(tp)    tthiwat[((tp)->t_cflag_ext&CBAUD)&TTMASK]
  219. #define    TTLOWAT(tp)    ttlowat[((tp)->t_cflag_ext&CBAUD)&TTMASK]
  220. extern    struct ttychars ttydefaults;
  221. #endif
  222.  
  223. /* internal state bits */
  224. #define    TS_TIMEOUT    0x000001    /* delay timeout in progress */
  225. #define    TS_WOPEN    0x000002    /* waiting for open to complete */
  226. #define    TS_ISOPEN    0x000004    /* device is open */
  227. #define    TS_FLUSH    0x000008    /* outq has been flushed during DMA */
  228. #define    TS_CARR_ON    0x000010    /* software copy of carrier-present */
  229. #define    TS_BUSY        0x000020    /* output in progress */
  230. #define    TS_ASLEEP    0x000040    /* wakeup when output done */
  231. #define    TS_XCLUDE    0x000080    /* exclusive-use flag against open */
  232. #define    TS_TTSTOP    0x000100    /* output stopped by ctl-s */
  233. #define    TS_HUPCLS    0x000200    /* hang up upon last close */
  234. #define    TS_TBLOCK    0x000400    /* tandem queue blocked */
  235. #define    TS_RCOLL    0x000800    /* collision in read select */
  236. #define    TS_WCOLL    0x001000    /* collision in write select */
  237. #define    TS_NBIO        0x002000    /* tty in non-blocking mode */
  238. #define    TS_ASYNC    0x004000    /* tty in async i/o mode */
  239. #define    TS_ONDELAY    0x008000    /* device is open; software copy of 
  240.                      * carrier is not present */
  241. /* state for intra-line fancy editing work */
  242. #define    TS_BKSL        0x010000    /* state for lowercase \ work */
  243. #define    TS_QUOT        0x020000    /* last character input was \ */
  244. #define    TS_ERASE    0x040000    /* within a \.../ for PRTRUB */
  245. #define    TS_LNCH        0x080000    /* next character is literal */
  246. #define    TS_TYPEN    0x100000    /* retyping suspended input (PENDIN) */
  247. #define    TS_CNTTB    0x200000    /* counting tab width; leave FLUSHO alone */
  248.  
  249.  
  250. #define    TS_IGNCAR    0x400000    /* ignore software copy of carrier */
  251. #define    TS_CLOSING    0x800000    /* closing down line */
  252. #define TS_INUSE    0x1000000    /* line is in use */
  253. #define TS_LRTO        0x2000000    /* Raw timeout - used with min/time */
  254. #define TS_LTACT    0x4000000    /* Timeout active, used with min/time */
  255. #define TS_ISUSP    0x8000000    /* Suspend input. */
  256. #define TS_OABORT    0x10000000      /* Output suspended on stop char. */
  257. #define TS_ONOCTTY    0x20000000      /* Don't get controlling tty on open */
  258.  
  259.  
  260. #define    TS_LOCAL    (TS_BKSL|TS_QUOT|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB)
  261.  
  262. /* define partab character types */
  263. #define    ORDINARY    0
  264. #define    CONTROL        1
  265. #define    BACKSPACE    2
  266. #define    NEWLINE        3
  267. #define    TAB        4
  268. #define    VTAB        5
  269. #define    RETURN        6
  270. #define    FORM_FEED    7
  271.  
  272. #ifdef KERNEL
  273. /* define some portability values for the clist functions */
  274. #define DELAY_FLAG    0400        /* indicates a delay character */
  275. #define QUOTE_FLAG    01000        /* character has been quoted */
  276. #define CHAR_MASK    0377        /* to get real character */
  277. #define DEL_CHAR    0177        /* the delete character */
  278. #endif
  279.